package com.ctrip.demo.leetcode;

public class LeetCode1688 {

    public static void main(String[] args) {
        System.out.println(numberOfMatches(7));
    }

    static int res = 0;
    public static int numberOfMatches(int n) {
        return dfs(n);
    }


    static int dfs(int n) {

        while(n != 1) {
            res += n / 2;

            n = (n + 1) / 2;
        }

        return res;

    }
}
